package com.dqyt.khjc.controller;

import com.dqyt.khjc.bean.ResultMsg;
import com.dqyt.khjc.service.ReportPcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class ReportPcController {


    @Autowired
    private ReportPcService reportPcService;


    /**
     * 分页查  我的报告（检测人是我）
     * @param request 请求
     * @param pageNum  页数
     * @param pageSize  每页条数
     * @param bsbh   标识编号
     * @param erweima  二维码
     * @param type  样品类型  1：呼吸器  2: 复合气瓶
     * @param reportStatue    报告状态 1：待检验  2：待核验 3：待批准  4：合格  5：不合格  6：驳回
     * @param wtfId  委托方id
     * @param spType 送检类型
     * @param  reportProgress 报告进度
     * @param  jyrqNian 送检日期按年搜
     * @param  jyrqYue 送检日期按年月搜
     * @return
     */
    @RequestMapping(value = "/api/getReportListPage", method = {RequestMethod.POST})
    public ResultMsg getReportListPage(HttpServletRequest request,
                                         @RequestParam(defaultValue = "1") Integer pageNum,
                                         @RequestParam(defaultValue = "10") Integer pageSize,
                                         @RequestParam(name = "bsbh", required = false, defaultValue = "")  String bsbh,
                                         @RequestParam(name = "erweima", required = false, defaultValue = "")  String erweima,
                                         @RequestParam(defaultValue = "0")Integer type,
                                         @RequestParam(defaultValue = "0") Integer reportStatue,
                                         @RequestParam(defaultValue = "-1") Integer wtfId,
                                         @RequestParam(defaultValue = "0") Integer spType,
                                         @RequestParam(defaultValue = "-1") Integer zzcsId,
                                         @RequestParam(defaultValue = "0") Integer reportProgress,
                                         @RequestParam(name = "jyrqNian", required = false, defaultValue = "")  String jyrqNian,
                                         @RequestParam(name = "jyrqYue", required = false, defaultValue = "")  String jyrqYue,
                                         @RequestParam(name = "jyyId", required = false, defaultValue = "")  String jyyId,
                                         @RequestParam(name = "rwdbh", required = false, defaultValue = "")  String rwdbh,
                                         @RequestParam(name = "sbbh", required = false, defaultValue = "")  String sbbh
    ){

        ResultMsg resultMsg = reportPcService.getReportListPage(request,pageNum, pageSize, bsbh, erweima, type, reportStatue, wtfId, spType,zzcsId,reportProgress,jyrqNian,jyrqYue,jyyId,rwdbh,sbbh);
        return resultMsg;
    }



    /**
     * 分页查  我的报告（检测人是我）
     * @param request 请求
     * @param pageNum  页数
     * @param pageSize  每页条数
     * @param bsbh   标识编号
     * @param erweima  二维码
     * @param type  样品类型  1：呼吸器  2: 复合气瓶
     * @param reportStatue    报告状态 1：待检验  2：待核验 3：待批准  4：合格  5：不合格  6：驳回
     * @param wtfId  委托方id
     * @param spType 送检类型
     * @param  reportProgress 报告进度
     * @param  jyrqNian 送检日期按年搜
     * @param  jyrqYue 送检日期按年月搜
     * @return
     */
    @RequestMapping(value = "/api/getReportListPage2", method = {RequestMethod.POST})
    public ResultMsg getReportListPage2(HttpServletRequest request,
                                       @RequestParam(defaultValue = "1") Integer pageNum,
                                       @RequestParam(defaultValue = "10") Integer pageSize,
                                       @RequestParam(name = "bsbh", required = false, defaultValue = "")  String bsbh,
                                       @RequestParam(name = "erweima", required = false, defaultValue = "")  String erweima,
                                       @RequestParam(defaultValue = "0")Integer type,
                                       @RequestParam(defaultValue = "0") Integer reportStatue,
                                       @RequestParam(defaultValue = "-1") Integer wtfId,
                                       @RequestParam(defaultValue = "0") Integer spType,
                                       @RequestParam(defaultValue = "-1") Integer zzcsId,
                                       @RequestParam(defaultValue = "0") Integer reportProgress,
                                       @RequestParam(name = "jyrqNian", required = false, defaultValue = "")  String jyrqNian,
                                       @RequestParam(name = "jyrqYue", required = false, defaultValue = "")  String jyrqYue,
                                       @RequestParam(name = "jyyId", required = false, defaultValue = "")  String jyyId,
                                       @RequestParam(name = "rwdbh", required = false, defaultValue = "")  String rwdbh

    ){

        ResultMsg resultMsg = reportPcService.getReportListPage2(request,pageNum, pageSize, bsbh, erweima, type, reportStatue, wtfId, spType,zzcsId,reportProgress,jyrqNian,jyrqYue,jyyId,rwdbh);
        return resultMsg;
    }


    /**
     * 分页查  我的报告（检测人是我）
     * @param request 请求
     * @param pageNum  页数
     * @param pageSize  每页条数
     * @param bsbh   标识编号
     * @param erweima  二维码
     * @param type  样品类型  1：呼吸器  2: 复合气瓶
     * @param reportStatue    报告状态 1：待检验  2：待核验 3：待批准  4：合格  5：不合格  6：驳回
     * @param wtfId  委托方id
     * @param spType 送检类型
     * @param  reportProgress 报告进度
     * @param  jyrqNian 送检日期按年搜
     * @param  jyrqYue 送检日期按年月搜
     * @return
     */
    @RequestMapping(value = "/api/getMyReportListPage", method = {RequestMethod.POST})
    public ResultMsg getMyReportListPage(HttpServletRequest request,
                                        @RequestParam(defaultValue = "1") Integer pageNum,
                                        @RequestParam(defaultValue = "10") Integer pageSize,
                                        @RequestParam(name = "bsbh", required = false, defaultValue = "")  String bsbh,
                                        @RequestParam(name = "erweima", required = false, defaultValue = "")  String erweima,
                                        @RequestParam(defaultValue = "0")Integer type,
                                        @RequestParam(defaultValue = "0") Integer reportStatue,
                                        @RequestParam(defaultValue = "-1") Integer wtfId,
                                         @RequestParam(defaultValue = "-1") Integer wtfIdChi,
                                        @RequestParam(defaultValue = "0") Integer spType,
                                        @RequestParam(defaultValue = "-1") Integer zzcsId,
                                        @RequestParam(defaultValue = "0") Integer reportProgress,
                                        @RequestParam(name = "jyrqNian", required = false, defaultValue = "")  String jyrqNian,
                                        @RequestParam(name = "jyrqYue", required = false, defaultValue = "")  String jyrqYue,
                                        @RequestParam(name = "rwdbh", required = false, defaultValue = "")  String rwdbh,
                                        @RequestParam(name = "sbbh", required = false, defaultValue = "")  String sbbh
                                         ){

        ResultMsg resultMsg = reportPcService.getMyReportListPage(request,pageNum, pageSize, bsbh, erweima, type, reportStatue, wtfId,wtfIdChi, spType,zzcsId,reportProgress,jyrqNian,jyrqYue,rwdbh,sbbh);
        return resultMsg;
    }



    /**
     * 成套查询报告
     * @param request 请求
     * @param pageNum  页数
     * @param pageSize  每页条数
     * @param bsbh   标识编号
     * @param erweima  二维码
     * @param type  样品类型  1：呼吸器  2: 复合气瓶
     * @param reportStatue    报告状态 1：待检验  2：待核验 3：待批准  4：合格  5：不合格  6：驳回
     * @param wtfId  委托方id
     * @param spType 送检类型
     * @param  reportProgress 报告进度
     * @param  jyrqNian 送检日期按年搜
     * @param  jyrqYue 送检日期按年月搜
     * @return
     */
    @RequestMapping(value = "/api/getMyReportTaoPage", method = {RequestMethod.POST})
    public ResultMsg getMyReportTaoPage(HttpServletRequest request,
                                         @RequestParam(defaultValue = "1") Integer pageNum,
                                         @RequestParam(defaultValue = "10") Integer pageSize,
                                         @RequestParam(name = "bsbh", required = false, defaultValue = "")  String bsbh,
                                         @RequestParam(name = "erweima", required = false, defaultValue = "")  String erweima,
                                         @RequestParam(defaultValue = "0")Integer type,
                                         @RequestParam(defaultValue = "0") Integer reportStatue,
                                         @RequestParam(defaultValue = "-1") Integer wtfId,
                                         @RequestParam(defaultValue = "0") Integer spType,
                                         @RequestParam(defaultValue = "-1") Integer zzcsId,
                                         @RequestParam(defaultValue = "0") Integer reportProgress,
                                         @RequestParam(name = "jyrqNian", required = false, defaultValue = "")  String jyrqNian,
                                         @RequestParam(name = "jyrqYue", required = false, defaultValue = "")  String jyrqYue
    ){

        ResultMsg resultMsg = reportPcService.getMyReportTaoPage(request,pageNum, pageSize, bsbh, erweima, type, reportStatue, wtfId, spType,zzcsId,reportProgress,jyrqNian,jyrqYue);
        return resultMsg;
    }





    /**
     * 报告状态合格
     * @param request
     * @param bsbh
     * @return
     */
    @RequestMapping(value = "/api/setBGHg", method = {RequestMethod.POST})
    public ResultMsg  setFhqpHg(HttpServletRequest request,int type,String bh,String bsbh){
        ResultMsg resultMsg = reportPcService.setFhqpHg(request,type,bh,bsbh);
        return resultMsg;
    }


    /**
     * 报告不合格(复合气瓶)
     * @param request
     * @param bsbh
     * @param failedStart
     * @param jl 结论
     * @return
     */
    @RequestMapping(value = "/api/reportFhqpFied", method = {RequestMethod.POST})
    public ResultMsg  reportFhqpFied(HttpServletRequest request,String bh,String bsbh,int failedStart,String jl){
        ResultMsg resultMsg = reportPcService.reportFhqpFied(request,bh,bsbh, failedStart,jl);
        return resultMsg;
    }





    /**
     * 报告不合格 压力表和 面罩
     * @param request
     * @param bsbh
     * @param failedStart
     * @param jl 结论
     * @return
     */
    @RequestMapping(value = "/api/reportFied", method = {RequestMethod.POST})
    public ResultMsg  reportFied(HttpServletRequest request,String bh,String bsbh,int failedStart,String jl,String nr_ypztms){
        ResultMsg resultMsg = reportPcService.reportFied(request,bh,bsbh, failedStart,jl,nr_ypztms);
        return resultMsg;
    }




    /**
     * 修改报告的进度
     * @param request
     * @param bsbh
     * @return
     */
    @RequestMapping(value = "/api/srtReportProgress", method = {RequestMethod.POST})
    public ResultMsg  srtReportProgress(HttpServletRequest request,String bh,String bsbh,int reportProgress){
        ResultMsg resultMsg = reportPcService.srtReportProgress(request,bh,bsbh, reportProgress);
        return resultMsg;
    }



    /**
     * 报告通过审核
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/reportAdoptExamine", method = {RequestMethod.POST})
    public ResultMsg  reportAdoptExamine(HttpServletRequest request,String bh){
        ResultMsg resultMsg = reportPcService.reportAdoptExamine(request,bh);
        return resultMsg;
    }




    /**
     * 报告通过批准
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/reportAdoptApproval", method = {RequestMethod.POST})
    public ResultMsg  reportAdoptApproval(HttpServletRequest request,String bh){
        ResultMsg resultMsg = reportPcService.reportAdoptApproval(request,bh);
        return resultMsg;
    }




    /**
     * 驳回报告
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/rejectReportDal", method = {RequestMethod.POST})
    public ResultMsg  refuseDal(HttpServletRequest request,String bh,int reportProgress,String bhgyy){
        ResultMsg resultMsg = reportPcService.rejectReportDal(request,bh, reportProgress,bhgyy);
        return resultMsg;
    }


    /**
     * 修改报告
     * @param request
     * @param objectJson
     * @return
     */
    @RequestMapping(value = "/api/updateReport", method = {RequestMethod.POST})
    public ResultMsg  updateReport(HttpServletRequest request,String objectJson){
        ResultMsg resultMsg = reportPcService.updateReport(request,objectJson);
        return resultMsg;
    }


    /**
     * 查询 检验时间即将到期的 报告
     * @param request
     * @param wtfId
     * @param month
     * @return
     */
    @RequestMapping(value = "/api/getReportOverdue", method = {RequestMethod.POST})
    public ResultMsg getReportOverdue(HttpServletRequest request,
                                      @RequestParam(name = "wtfId", required = false, defaultValue = "0") String wtfId,
                                      int month,
                                      @RequestParam(name = "wtfIdChi", required = false, defaultValue = "0") String wtfIdChi){
        ResultMsg resultMsg = reportPcService.getReportOverdue(request,wtfId,month,wtfIdChi);
        return resultMsg;
    }


    /**
     * 删除报告
     * @param request
     * @param  bh
     * @return
     */
    @RequestMapping(value = "/api/mdelBGHg", method = {RequestMethod.POST})
    public ResultMsg  deleteBg(HttpServletRequest request,String bh,String bsbh){
        ResultMsg resultMsg = reportPcService.deleteBg(request,bh,bsbh);
        return resultMsg;
    }


    /**
     * 直接生成气瓶报废的报告
     * @param request
     * @return
     */
    @RequestMapping(value = "/api/setBfReport", method = {RequestMethod.POST})
    public ResultMsg  setBfReport(HttpServletRequest request,String bsbh,String jl){
        ResultMsg resultMsg = reportPcService.setBfReport(request,bsbh,jl);
        return resultMsg;
    }


}
